package com.smasher.net.util

import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody.Companion.asRequestBody
import okhttp3.RequestBody.Companion.toRequestBody
import org.json.JSONObject
import java.io.File

object RequestBodyUtil {

    fun createJSONBody(json: JSONObject): okhttp3.RequestBody {
        return json.toString().toRequestBody("application/json; charset=utf-8".toMediaType())
    }

    fun createBody(content: String): okhttp3.RequestBody {
        return content.toRequestBody("application/json; charset=utf-8".toMediaType())
    }

    fun createBodyFile(file: File): okhttp3.RequestBody {
        return file.asRequestBody("image/jpg".toMediaType())
    }
}